<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Payset extends CI_Controller
{
    private $assign = array();

    function __construct()
    {
        parent::__construct();

        $data['type'] = $this->uri->segment(3);
        $this->assign['auth'] = explode(',', $this->input->get('auth'));
    }

    //支付设定
    public function index()
    {
        $data = array_merge($this->assign, array());
        $this->load->view('payset/list', $data);
    }

    //获取支付设定
    public function get_pay_types()
    {
        $data = array(
            'total' => 3,
            'rows'  =>  array(
                array('id'=>1, 'type'=>'默认支付设定', 'can_del'=>0),
                array('id'=>2, 'type'=>'送优惠支付设定', 'can_del'=>1),
                array('id'=>3, 'type'=>'18元优惠','can_del'=>1),
            ),
        );

        echo json_encode($data, JSON_UNESCAPED_UNICODE);
    }

    public function del_pay_type()
    {
        $id = $this->input->post('id');
        $data = array(
            'code'  =>  '0',
            'msg'   =>  '删除成功',
        );

        return json_encode($data, JSON_UNESCAPED_UNICODE);
    }

    //修改支付设定
    public function edit_pay_setting()
    {
        $this->load->view('payset/edit_pay_setting');
    }

    public function edit_pay_setting_do()
    {
        echo '{"status":0, "message":""}';
    }

    public function bankset()
    {
        $data['type'] = $this->uri->segment(3);
        $data['auth'] = explode(',', $this->input->get('auth'));
        $this->load->view('payset/bankset', $data);
    }

    public function get_bank_list()
    {
        $data = array(
            'total' => 3,
            'rows' => array(
                array('id' => 1, 'bank' => '中国银行', 'bank_acc' => '中国银行深圳南山支行', 'bank_no' => '6225881275848775',
                    'person_name' => '刘辉', 'money' => '1000000', 'status' => 1, 'remark' => ''),
                array('id' => 1, 'bank' => '中国银行', 'bank_acc' => '中国银行深圳南山支行', 'bank_no' => '6225881275848775',
                    'person_name' => '刘辉', 'money' => '1000000', 'status' => 0, 'remark' => ''),
                array('id' => 1, 'bank' => '中国银行', 'bank_acc' => '中国银行深圳南山支行', 'bank_no' => '6225881275848775',
                    'person_name' => '刘辉', 'money' => '1000000', 'status' => 1, 'remark' => ''),
            ),
        );

        echo json_encode($data);
    }

    //编辑入款银行
    public function edit_bank()
    {
        $assign['data'] = array();
        $this->load->view('payset/edit_bank.php', $assign);
    }

    //修改支付信息
    public function edit_pay_info()
    {
        $this->load->view('payset/edit_pay_info');
    }

    //银行存款记录
    public function list_bank_deposit()
    {
        $data = array_merge($this->assign, array());

        $this->load->view('payset/list_bank_deposit', $data);
    }

    public function get_bank_deposit_list()
    {
        $post = $this->input->post();
//        var_dump($post);
        $data = array(
            'total' => 3,
            'rows' => array(
                array('id' => '1', 'order_num' => '13330388291', 'money' => 7999, 'date' => '2017-06-13 12:33:22', 'username' => 'ikaoj', 'remark' => '中国银行,5252,2017-02-15 16:58:20,网银转帐'),
                array('id' => '2', 'order_num' => '13330388291', 'money' => 7999, 'date' => '2017-06-13 12:33:22', 'username' => 'ikaoj', 'remark' => '中国银行,5252,2017-02-15 16:58:20,网银转帐'),
                array('id' => '3', 'order_num' => '13330388291', 'money' => 7999, 'date' => '2017-06-13 12:33:22', 'username' => 'ikaoj', 'remark' => '中国银行,5252,2017-02-15 16:58:20,网银转帐'),
            ),
            'footer' => array(
                array('order_num' => '小计', 'money' => 7999),
                array('order_num' => '总计', 'money' => 100000),
            ),
        );

        echo json_encode($data, JSON_UNESCAPED_UNICODE);
    }

    //线上支付设定列表
    public function online_pay_setting()
    {
        $data = array_merge(array(), $this->assign);

        $this->load->view('payset/online_pay_setting', $data);
    }

    //获取线上支付设定
    public function get_online_pay_setting()
    {
        $post = $this->input->post();
//        var_dump($post);
        $data = array(
            'total' => 3,
            'rows' => array(
                array('id' => '1', 'platform' => '聚源', 'business_id' => 79995226632, 'day_pay_limit' => 5000, 'status' => 1),
                array('id' => '3', 'platform' => 'OK付', 'business_id' => 79995226632, 'day_pay_limit' => 7000, 'status' => 0),
                array('id' => '3', 'platform' => '讯汇宝', 'business_id' => 79995226632, 'day_pay_limit' => 5000, 'status' => 1),
            ),
        );

        echo json_encode($data, JSON_UNESCAPED_UNICODE);
    }

    //修改线上支付设定
    public function edit_online_pay_setting()
    {
        $edit_status = $this->input->post('edit_status');

        echo json_encode(
            array(
                'author' => 'yunshu',
                'email' => 'kkojj@163.com',
                'response_time' => 3,
                'data' => array(),
                'code' => 0,
                'msg' => '删除成功',
            ), JSON_UNESCAPED_UNICODE);
    }

    //删除线上支付设定
    public function del_online_pay_setting()
    {
        echo json_encode(array(
            'author' => 'yunshu',
            'email' => 'kkojj@163.com',
            'response_time' => 3,
            'data' => array(),
            'code' => 0,
            'msg' => '删除成功',
        ), JSON_UNESCAPED_UNICODE);
    }

    public function online_pay_list()
    {
        $data = array_merge($this->assign, array());

        $this->load->view('payset/online_pay_list', $data);
    }

    //获取线上支付付款记录
    public function get_online_pay_list()
    {
        $post = $this->input->post();
//        var_dump($post);
        $data = array(
            'total' => 3,
            'rows' => array(
                array('id' => '1', 'order_num' => '522244477783', 'money'=>150, 'date'=>'2017-02-15 14:58:27', 'username'=>'shen2', 'remark'=>'聚源支付，2017-02-15 16:58:20'),
                array('id' => '2', 'order_num' => '522244477783', 'money'=>1050, 'date'=>'2017-02-15 14:58:27', 'username'=>'jkaolq', 'remark'=>'聚源支付，2017-02-15 16:58:20'),
                array('id' => '3', 'order_num' => '522544477783', 'money'=>1500, 'date'=>'2017-02-15 14:58:27', 'username'=>'kkaolq', 'remark'=>'聚源支付，2017-02-15 16:58:20'),
            ),
            'footer' => array(
                array('order_num' => '小计', 'money' => 7999),
                array('order_num' => '总计', 'money' => 100000),
            ),
        );

        echo json_encode($data, JSON_UNESCAPED_UNICODE);
    }
}
